package com.framework.main.sys.user.dao; 

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.framework.main.sys.module.domain.ModuleVO;

/**
 * @Description:  用户管理:权限
 * @Copyright: Copyright (c) 2011
 * @date:Jun 14, 2011
 * @version: 1.0
 */

public class ModuleOperation {
	private static UserDao userDao; 
	
	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDaos) {
		userDao = userDaos;
	}

	/**
	 * 获得所有的菜单级权限
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public static List allModules() throws Exception{
		List list = new ArrayList();
		
		list = userDao.queryForList("toListModu", null);
		
		return list;
	}
	

	/**
	 * 获得所有菜单下铵扭的权限
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public static List moduleOperations() throws Exception{
		Map temp = new HashMap();
		
		List allModule = ModuleOperation.allModules();
        for (int j = 0; j < allModule.size(); j++) {
        	ModuleVO mo = (ModuleVO) allModule.get(j);
            String ID = mo.getModuleIdf();
            List oper = userDao.queryForList("toListModuOper", ID);
            temp.put(ID, oper); //获得菜单下铵扭的权限集合保存Map
        }
        List list = new ArrayList();
        list.add(temp);
		
		return list;		
	}
}
